/********************************************************************************
 * UserServiceDelegator.java
 *
 * Created by Nishan Patel
 * Last modified Date: Nov 26, 2008 11:13:51 AM by Nishan Patel
 * Version : 0.1
 * Copyright (c) 2008 - 2009 cyberThink Infotech Pvt. Ltd., All rights reserved.
 ********************************************************************************/
package com.printeverywhere.delegator;

import static com.printeverywhere.util.AttributeConstants.CLOSING_SESSION;

import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.printeverywhere.dto.ContactUs;
import com.printeverywhere.util.HibernateUtil;

// TODO: Auto-generated Javadoc
/**
 * The Class AccountTypeServiceDelegator.
 */
public class ContactUsServiceDelegator {

	/** The log. */
	private static Logger log = Logger.getLogger(ContactUsServiceDelegator.class);

	/**
	 * Insert account type.
	 *
	 * @param accountType the account type
	 *
	 * @throws HibernateException the hibernate exception
	 */
	public static void insertContactUs(ContactUs contactUs) throws HibernateException {
		if(log.isInfoEnabled()){
			log.info("Called insertContactUs method".intern());
		}
		Session session = HibernateUtil.getSession();
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
			session.save(contactUs);
			tx.commit();
		} catch (RuntimeException e) {
			log.error("Got exception when insert ContactUs".intern());
			if (tx != null)
				tx.rollback();
			throw e;
		} finally {
			if(log.isInfoEnabled()){
				log.info(CLOSING_SESSION);
			}
			session.flush();
			session.close();
		}
	}
}